<div class="sidebar-menu">

    <div class="sidebar-menu-inner">
      
      <header class="logo-env">

        <!-- logo -->
        <div class="logo">
          <a href="{:U('/index')}">
            <img src="__PUBLIC__/assets/images/logo@2x.png" width="120" alt="" />
          </a>
        </div>

        <!-- logo collapse icon -->
        <div class="sidebar-collapse">
          <a href="#" class="sidebar-collapse-icon"><!-- add class "with-animation" if you want sidebar to have animation during expanding/collapsing transition -->
            <i class="entypo-menu"></i>
          </a>
        </div>

                
        <!-- open/close menu icon (do not remove if you want to enable menu on mobile devices) -->
        <div class="sidebar-mobile-menu visible-xs">
          <a href="#" class="with-animation"><!-- add class "with-animation" to support animation -->
            <i class="entypo-menu"></i>
          </a>
        </div>

      </header>
      <php>
use Common\Controller\AuthController;
use Think\Auth;
    $m = M('auth_rule_home');
    $field = 'id,name,title,css';
      $data = $m->field($field)->where('pid=0 AND status=1')->order('sort')->select();     
      $auth = new Auth();
      //没有权限的菜单不显示
      foreach ($data as $k=>$v){
        if(!$auth->check($v['name'], $_SESSION['home_aid']) && $_SESSION['home_aid'] != 1){
          unset($data[$k]);
        }
      }

</php>
                  
      <ul id="main-menu" class="main-menu">
        <!-- add class "multiple-expanded" to allow multiple submenus to open -->
        <!-- class "auto-inherit-active-class" will automatically add "active" class for parent elements who are marked already with class "active" -->
        

      <foreach name="data" item="v">
      <li class="root-level has-sub <if condition="CONTROLLER_NAME eq $v['name']">active opened</if>"><!--open代表打开状态-->
        <a href="#">
          <i class="menu-icon fa {$v.css}"></i>
          <span class="nav-label">{$v.title}</span><span class="fa arrow"></span>
        </a>

      <ul class="nav nav-second-level">
    <php>
    $m = M('auth_rule_home');
      $dataa = $m->where(array('pid'=>$v['id'],'status'=>1))->order('sort')->select();
      foreach ($dataa as $kk=>$vv){
        if(!$auth->check($vv['name'], $_SESSION['home_aid']) && $_SESSION['home_aid'] != 1){
          unset($dataa[$kk]);
        }
      }
  
    </php>
        <foreach name="dataa" item="j">
          <li class=" <if condition="($_GET['se'] eq $j['id'])">active</if>">
            <a href="{:U($j['name'],array('se'=>$j['id']))}">{$j.title}</a>           
          </li>
      </foreach>
      </ul>
    </li>
  </foreach>

      </ul>
      
    </div>

  </div>